<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>修改密码</title>
        <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport"/>
        <meta content="yes" name="apple-mobile-web-app-capable"/>
        <meta content="black" name="apple-mobile-web-app-status-bar-style"/>
        <meta content="telephone=no" name="format-detection"/>
        <link href="css/login.css" rel="stylesheet" type="text/css"/>        
        <script type="text/javascript" src="js/jquery.min.js" ></script>
        <link href="css/aui/aui.css" rel="stylesheet" type="text/css"/>
        <script type="text/javascript" src="js/aui/aui-dialog.js" ></script>

    </head>
    <body>
        <section class="aui-flexView">
            <header class="aui-navBar aui-navBar-fixed b-line">
                <a href="modify" class="aui-navBar-item">
                    <i class="icon icon-return"></i>
                </a>
                <div class="aui-center">
                    <span class="aui-center-title" style="font-size: 16px;">修改密码</span>
                </div>
            </header>#include('header.html')
            <section class="aui-scrollView">
                <div class="aui-code-box">
                    <form action="" method="post" onsubmit="return checkform()">
                        <p class="aui-code-line aui-code-line-clear">
                            <input type="password" name="pass1" class="aui-code-line-input password" id="mima1" placeholder="当前密码" value="">
                        </p>
                        <p class="aui-code-line aui-code-line-clear">
                            <input type="password" name="pass2" class="aui-code-line-input password1" id="mima2" placeholder="新的密码" value="">
                        </p>
                        <p class="aui-code-line aui-code-line-clear">                       
                            <input type="password" class="aui-code-line-input password1" id="mima3" placeholder="确认密码" value="">
                        </p>
                        <div class="aui-code-btn">
                            <button style="font-size: 16px;">提交</button>
                        </div>
                    </form>
                </div>
            </section>
        </section>   

                <script type="text/javascript">
                    var dialog = new auiDialog({})
                        function checkform(){
                             
                            var pass1=document.getElementById("mima1").value;
                            var pass2=document.getElementById("mima2").value;
                            var pass3=document.getElementById("mima3").value;
                            if(pass1==""||pass1.length<6||pass2.length<6){
                                dialog.alert({
                                        // title:"用户名",
                                        msg:'密码长度不少于6个字符！',
                                        buttons:['确定']
                                    },function(ret){
                                        console.log(ret)
                                    });
                                return false;
                            }
                            else {
                                if(pass1==pass2){
                                dialog.alert({
                                        // title:"用户名",
                                        msg:'新旧密码相同！',
                                        buttons:['确定']
                                    },function(ret){
                                        console.log(ret)
                                    });
                                return false;
                            }
                            else {
                                if(pass2!=pass3){
                                dialog.alert({
                                        msg:'两次密码输入不一致！',
                                        buttons:['确定']
                                    },function(ret){
                                        console.log(ret)
                                    });
                                return false;
                            }

                            else{
                                $.ajax({
                                        url:"do_modify_pass",
                                        dataType:"json",
                                        type:"post",
                                        data:$("form").serialize(),
                                        success:function(result){
                                            if(result.status=="1"){
                                                dialog.alert({
                                                    msg:'密码修改成功，请重新登录。',
                                                    buttons:['确定']
                                                },function(ret){
                                                    window.location.href="/logout";
                                                });
                                            }
                                            else {
                                                dialog.alert({
                                                    msg:''+result.tips,
                                                    buttons:['确定']
                                                });
                                            }
                                        },
                                        error:function(result){
                                            console.log(result);
                                            dialog.alert({
                                                msg:'系统繁忙！',
                                                buttons:['确定']
                                            });
                                        }
                                    });
                                return false;
                            }


                            return true;
                            }
                        }
                    }
                    </script>   

    </body>
</html>
